package com.flycms.module.app.enums;

import lombok.Getter;

import java.util.Objects;

public enum AppTypeEnum {
    DEV(1,"设计研发设计类"),
    PRODUCT(2,"生产制造类"),
    MANAGER(3,"经营管理类"),
    OPS(4,"运维服务类"),
    PROTECT(5,"疫情防护类");

    AppTypeEnum(Integer code, String desc){
        this.code = code;
        this.desc = desc;
    }

    @Getter
    Integer code;

    @Getter
    String desc;

    /**
     * 根据code值获取枚举描述
     * @param code 值
     * @return 对应描述
     */
    public static String getDescByCode(Integer code) {
        if(Objects.isNull(code)){
            return "";
        }
        AppTypeEnum[] values = values();
        for (AppTypeEnum anEnum : values) {
            if(code == anEnum.getCode()){
                return anEnum.getDesc();
            }
        }
        return "";
    }
}
